﻿@model SimpleTaskManager.Domain.Entities.Task

@{
    ViewBag.Title = "Create new task";
}

<h2>Create new task</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm(new { parentId = ViewBag.ParentId }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Task</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.EndDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EndDate)
            @Html.ValidationMessageFor(model => model.EndDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LeaderId)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.LeaderId, 
            (ViewBag.UserList as IEnumerable<SimpleTaskManager.Domain.Entities.User>).Select(u => new SelectListItem{Text = u.LastName + ", " + u.FirstName, Value = u.UserID.ToString()}))
            @Html.ValidationMessageFor(model => model.LeaderId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.GroupSize)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.GroupSize)
            @Html.ValidationMessageFor(model => model.GroupSize)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div style="clear: left;" />

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Details", new { id = ViewBag.ParentId })
</div>
